#ifndef _SOFT_I2c_H
#define _SOFT_I2c_H

#include "stdint.h"

typedef struct i2c_bit_ops
{
    void (*set_sda)(int32_t state);
    void (*set_scl)(int32_t state);
    int32_t (*get_sda)(void);
  
    void (*udelay)(uint32_t us);

    uint32_t delay_us;  /* scl and sda line delay */
    uint8_t  writeAddr;
    uint32_t waitTime;  /* scl and sda line delay */
}soft_i2c_driver;

void soft_i2c_start(soft_i2c_driver *i2c_driver);
void soft_i2c_stop(soft_i2c_driver *i2c_driver);
uint8_t soft_i2c_waitAck(soft_i2c_driver *i2c_driver);
void soft_i2c_Send(soft_i2c_driver *i2c_driver,uint8_t data);
uint8_t soft_i2c_Receive(soft_i2c_driver *i2c_driver);

uint8_t soft_i2c_WriteBytes(soft_i2c_driver *i2c_driver,uint8_t data[],uint8_t size);
uint8_t soft_i2c_ReadBytes(soft_i2c_driver *i2c_driver,uint8_t reg, uint8_t data[],uint8_t size);

uint8_t soft_i2c_WriteReg_8Bits(soft_i2c_driver *i2c_driver, uint8_t reg, uint8_t reg_data);
uint8_t soft_i2c_WriteReg_16Bits(soft_i2c_driver *i2c_driver, uint8_t reg, uint16_t reg_data);

uint8_t soft_i2c_ReadReg_8Bits(soft_i2c_driver *i2c_driver,uint8_t reg);
uint16_t soft_i2c_ReadReg_16Bits(soft_i2c_driver *i2c_driver,uint8_t reg);

void soft_i2c_addr_set(soft_i2c_driver *i2c_driver,uint8_t writeAddr);
void soft_i2c_init(soft_i2c_driver *i2c_driver, 
                  void (*set_sda)(int32_t state), void (*set_scl)(int32_t state),
                  int32_t (*get_sda)(void),void (*udelay)(uint32_t us), 
				  uint8_t writeAddr, uint32_t delay_us,uint32_t waitTime);

#endif
